package com.panopset.gui;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import com.panopset.java.Version;
import com.panopset.swing.FontManager;

/**
 *
 * Standard Panopset Swing button.
 *
 * @author Karl Dinwiddie
 */
public class TButton extends JButton {

    /**
     * Default height is 20.
     */
    private static final int DEFAULT_HEIGHT = 20;

    /**
     * Create a simple button, no label.
     */
    public TButton() {
        init();
    }

    /**
     * @param text
     *            Label.
     */
    public TButton(final String text) {
        this();
        setText(text);
    }

    /**
     * @param text
     *            Button name.
     * @param tip
     *            Tool tip text.
     */
    public TButton(final String text, final String tip) {
        this(text);
        setToolTipText(tip);
    }

    /**
     * @param text
     *            Button name.
     * @param tip
     *            Tool tip text.
     * @param listener
     *            Action listener.
     */
    public TButton(final String text, final String tip,
            final ActionListener listener) {
        this(text);
        setToolTipText(tip);
        this.addActionListener(listener);

    }

    /**
     * @param text
     *            Button name.
     * @param mnemonic
     *            Mnemonic.
     * @param tip
     *            Tool tip text.
     * @param listener
     *            Action listener.
     */
    public TButton(final String text, final int mnemonic, final String tip,
            final ActionListener listener) {
        this(text, tip, listener);
        this.setMnemonic(mnemonic);
    }

    /**
     * @param text
     *            Button name.
     * @param mnemonic
     *            Mnemonic.
     * @param tip
     *            Tool tip text.
     */
    public TButton(final String text, final int mnemonic, final String tip) {
        this(text, tip);
        setMnemonic(mnemonic);
    }

    @Override
    public int getHeight() {
        return DEFAULT_HEIGHT;
    }

    /**
     * Initialize the font.
     */
    private void init() {
        FontManager.register(this, FontManager.FontType.plainArial);
    }

    /**
     * Serial version id.
     */
    private static final long serialVersionUID = Version.UNI_VERSION;
}
